import { createSlice } from '@reduxjs/toolkit'
// Define the initial state using that type
const initialState = {
  caseEditVersion: Date.now(),
  caseDetail: null,
  caseListVersion: Date.now(),
  arbitratorVersion: Date.now()
}

export const casesSlice = createSlice({
  name: 'cases',
  // `createSlice` will infer the state type from the `initialState` argument
  initialState,
  reducers: {
    refreshCaseEditVersion: (state) => {
      state.caseEditVersion = Date.now()
    },
    refreshCaseListVersion: (state) => {
      state.caseListVersion = Date.now()
    },
    setCaseDetail: (state, action) => {
      state.caseDetail = action.payload
    },
    refreshArbitratorVersion: (state) => {
      state.arbitratorVersion = Date.now()
    },
  },
})

export const { refreshCaseEditVersion,  setCaseDetail, refreshCaseListVersion, refreshArbitratorVersion } = casesSlice.actions

export default casesSlice.reducer